package com.readnote.center;

import java.util.Collection;

import com.cr.backbone.action.AppBaseActionSupport;
import com.readnote.book.model.Book;
import com.readnote.book.model.UserNote;
import com.readnote.book.service.BookService;
import com.readnote.book.service.UserNoteService;
import com.readnote.expostulation.model.Expostulation;
import com.readnote.expostulation.service.ExpostulationService;
import com.readnote.user.model.User;

public class HomeAction extends AppBaseActionSupport {

	private BookService bookService;
	private UserNoteService userNoteService;
	private ExpostulationService expostulationService;
	private Collection<Book> books;
	private UserNote userNote;//笔记
	private Expostulation expostulation;//心得

	public BookService getBookService() {
		return bookService;
	}

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}

	public String index() {
		books=bookService.getList();
		User user=getLoginInfo().getUser();
		userNote=userNoteService.getUserNoteTopOneByUser(user);
		expostulation = expostulationService.getExpostulationTopOneByCreateDateDesc(user);
		return "index";
	}
	
	public void list(Collection<Book> list){
		for(Book book : list){
			System.out.println("------------------------");
			System.out.println(book.getId());
			System.out.println(book.getTitle());
			System.out.println(book.getContent());
			System.out.println(book.getBookface());
		}
	}

	public Collection<Book> getBooks() {
		return books;
	}

	public void setBooks(Collection<Book> books) {
		this.books = books;
	}

	public UserNoteService getUserNoteService() {
		return userNoteService;
	}

	public void setUserNoteService(UserNoteService userNoteService) {
		this.userNoteService = userNoteService;
	}

	public ExpostulationService getExpostulationService() {
		return expostulationService;
	}

	public void setExpostulationService(ExpostulationService expostulationService) {
		this.expostulationService = expostulationService;
	}

	public UserNote getUserNote() {
		return userNote;
	}

	public void setUserNote(UserNote userNote) {
		this.userNote = userNote;
	}

	public Expostulation getExpostulation() {
		return expostulation;
	}

	public void setExpostulation(Expostulation expostulation) {
		this.expostulation = expostulation;
	}

}
